﻿using System;
using System.Collections.Generic;
using System.Text;
using Framework.Platform.Components.UI.View;
using Framework.Platform.Components;

namespace Framework.Demo
{
    public class NavigatorDataLoaderDemo : INavigatorDataLoader
    {
        #region INavigatorDataLoader Members

        public void LoadData(string parentKey)
        {
            IList<NavigatorItemBase> datas = new List<NavigatorItemBase>();
            if (string.IsNullOrEmpty(parentKey))
            {
                GenericNavigatorItem<string> item = new GenericNavigatorItem<string>();
                item.IsLeaf = true;
                item.Key = "TestListModuleView";
                item.Text = "列表模块视图";
                item.Value = "TestListModuleView";
                item.Link = "TestListModuleView";
                datas.Add(item);

                item = new GenericNavigatorItem<string>();
                item.IsLeaf = true;
                item.Key = "TestDetailModuleView";
                item.Text = "明细模块视图";
                item.Value = "TestDetailModuleView";
                item.Link = "TestDetailModuleView";
                datas.Add(item);

                item = new GenericNavigatorItem<string>();
                item.IsLeaf = true;
                item.Key = "TestListDetailModuleView";
                item.Text = "列表明细模块视图";
                item.Value = "TestListDetailModuleView";
                item.Link = "TestListDetailModuleView";
                datas.Add(item);

                item = new GenericNavigatorItem<string>();
                item.IsLeaf = true;
                item.Key = "TestCustomModuleView";
                item.Text = "自定义模块视图";
                item.Value = "TestCustomModuleView";
                item.Link = "TestCustomModuleView";
                datas.Add(item);
            }
            NavigatorDataLoadedEventArgs arg = new NavigatorDataLoadedEventArgs();
            arg.Datas = datas;
            arg.IsSuccess = true;
            arg.ParentKey = parentKey;
            this.OnDataLoaded(arg);
        }


        public event EventHandler<NavigatorDataLoadedEventArgs>  DataLoaded;

        protected void OnDataLoaded(NavigatorDataLoadedEventArgs e)
        {
            if (DataLoaded != null)
            {
                DataLoaded(this, e);
            }
        }
        #endregion
    }
}